
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/admin/layui-v2.4.5/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="/admin/css/admin.css"  media="all">
    <link rel="stylesheet" href="/admin/css/template.css"  media="all">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>

<script src="/admin/layui-v2.4.5/layui/layui.js" charset="utf-8"></script>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">操作</div>
                        <div class="layui-card-body">

                            <div class="layui-carousel layadmin-carousel layadmin-shortcut">
                                <div carousel-item>
                                    <ul class="layui-row layui-col-space10"lay-filter="huhuhu">
                                        <li class="layui-col-xs6" id="out">
                                            <a>
                                                <i class="layui-icon layui-icon-cart-simple"></i>
                                                <cite>收费</cite>
                                            </a>

                                        </li>
                                        <!--<li class="layui-col-xs6"id="inv">-->
                                            <!--<a >-->
                                                <!--<i class="layui-icon layui-icon-list"></i>-->
                                                <!--<cite>库存详情</cite>-->
                                            <!--</a>-->
                                        <!--</li>-->
                                        <li class="layui-col-xs6" id="in">
                                            <a >
                                                <i class="layui-icon layui-icon-chat"></i>
                                                <cite>进货</cite>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs6"id="medicine">
                                            <a>
                                                <i class="layui-icon layui-icon-template-1"></i>
                                                <cite>药房详情</cite>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs6"id="kuai">
                                        <a >
                                        <i class="layui-icon layui-icon-list"></i>
                                        <cite>快速出库</cite>
                                        </a>
                                        </li>

                                    </ul>


                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">今日药房概况</div>
                        <div class="layui-card-body">

                            <div class="layui-carousel layadmin-carousel layadmin-backlog">
                                <!--<div carousel-item>-->
                                        <li class="layui-col-xs6">
                                            <a id="li1"class="layadmin-backlog-body">
                                                <h3>已取药人数</h3>
                                                <p><cite id="h1"></cite></p>
                                            </a>
                                        </li>
                                        <li class="layui-col-xs6">
                                            <a id="li2" class="layadmin-backlog-body">
                                                <h3>未取药人数</h3>
                                                <p><cite id="h2"></cite></p>
                                            </a>
                                        </li>
                                       <li class="layui-col-xs6">
                                           <a id="li3" class="layadmin-backlog-body">
                                        <h3>今日销售额/元</h3>
                                        <p><cite id="h3"></cite></p>
                                            </a>
                                      </li>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">数据分析</div>
                        <div class="layui-card-body">

                            <div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-dataview">
                                <div carousel-item id="LAY-index-dataview">
                                    <div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
                                    <div></div>
                                    <div></div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-col-md4">

            <div class="layui-card">
                <div class="layui-card-header">药房动态</div>
                <div class="layui-card-body">
                    <dl class="layuiadmin-card-status">

                    </dl>
                </div>
            </div>

        </div>

    </div>
</div>
<button type="button" id="idUpload" style="display: none;">上传图片</button>

<script>
    layui.use(['layer','form','upload'], function() {
        var $ = layui.$ //由于layer弹层依赖jQuery，所以可以直接得到
            , layer = layui.layer
            , form = layui.form,
            upload=layui.upload;
        upload.render({
            elem: '#idUpload'
            , url: '/excelImport.do'
            ,exts: 'xls|xlsx'
            , accept: 'file' //普通文件
            , done: function (res) {
                console.log(res)
                if(res.code == 1){//成功的回调
                    var index=layer.open({
                        type: 2,
                        area: ['700px', '500px'],
                        fixed: false,
                        maxmin: true,
                        shadeClose: true,
                        content: 'med-in.html'
                    });
                    layer.full(index);
                    layer.msg("导入成功")
                }else{
                    layer.msg("出错啦");
                }
            }
        });
        function test() {
            $('#idUpload').click();
        }
        $(document).ready(function () {

            $.ajax({
                url: '/hospital/sale/all',
                dataType: 'json',
                type: 'get',
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    $.each(data.data, function (index, item) {
                        $('.layuiadmin-card-status').append("<dd>\n" +
                            "                            <div class=\"layui-status-img\"><a href=\"javascript:;\"></a></div>\n" +
                            "                            <div>\n" +
                            "                                <p><a>" + item.pat_name + "</a> 取走" + item.count + "盒" + item.mdc_name + "</p>\n" +
                            "                                <span>" + item.time + "</span>\n" +
                            "                            </div>\n" +
                            "                        </dd>")
                    })
                }

            })

            $.ajax({
                url: '/hospital/allSup',
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    $.each(data.data, function (index, item) {
                        $('#supcoin').append("<option value = '" + item.id + "'>" + item.sup_name + "</option>");// 下拉菜单里添加元素
                    });
                    form.render('select')


                }
            })
            $.ajax({
                url: '/hospital/checkPatStatue',
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    $.each(data.data, function (index, item) {
                        $("#h1").text(item.s3);
                        $("#h2").text(item.s2);
                        $("#h3").text(item.money);
                    })
                }
            })



        });
        // $(document).ready(function () {
        //
        // });
        $(document).on('click', '#li1', function () {


            var index = layer.open({
                type: 2,
                area: ['700px', '500px'],
                fixed: false,
                maxmin: true,
                shadeClose: true,
                content: 'med-allPat2.html'
            });
            layer.full(index);

        });
        $(document).on('click', '#li2', function () {


            var index1 = layer.open({
                type: 2,
                area: ['700px', '500px'],
                fixed: false,
                maxmin: true,
                shadeClose: true,
                content: 'med-allPat1.html'
            });
            layer.full(index1);

        });
        // $(document).on('click', '#li3', function () {
        //
        //
        //     var index = layer.open({
        //         type: 2,
        //         area: ['700px', '500px'],
        //         fixed: false,
        //         maxmin: true,
        //         shadeClose: true,
        //         content: 'med-money.html'
        //     });
        //     layer.full(index);
        //
        // });
        $(document).on('click', '#out', function () {


            layer.open({
                type: 2,
                area: ['700px', '500px'],
                fixed: false,
                maxmin: true,
                shadeClose: true,
                content: 'iframe.html'
            });

        });
        $(document).on('click', '#in', function () {
            var indexcon=layer.confirm('请选择导入方式', {
                btn: ['单个导入','EXCEL导入'] //按钮
            }, function(){
                layer.open({
                    type: 2,
                    area: ['500px', '460px'],
                    fixed: false,
                    maxmin: true,
                    shadeClose: true,
                    content: 'medFrame.html'
                });
                layer.close(indexcon);
            }, function(){
                test();
            });


        });
        $(document).on('click', '#medicine', function () {

            var index2=layer.open({
                type: 2,
                area: ['700px', '450px'],
                fixed: false,
                maxmin: true,
                shadeClose: true,
                content: 'medicine.html'
            });
            layer.full(index2);
            $.ajax({
                url: '/hospital/medInv',
                dataType: 'json',
                type: 'get',
                success: function (data) {
                    var obj = eval(data.data[0]);
                    console.log(obj);
                    if (data.code==1){
                        var indexcon1=layer.confirm(obj.med+'库存不足，是否补充？', {
                            btn: ['补充','忽略'] //按钮
                        }, function(){
                            layer.close(index2);
                            layer.close(indexcon1);
                            var indexcon2=layer.confirm('请选择导入方式', {
                                btn: ['单个导入','EXCEL导入'] //按钮
                            }, function(){
                                layer.open({
                                    type: 2,
                                    area: ['500px', '460px'],
                                    fixed: false,
                                    maxmin: true,
                                    shadeClose: true,
                                    content: 'medFrame.html'
                                });
                                layer.close(indexcon2);
                            }, function(){
                                test();
                            });
                        }, function(){
                            $.ajax({
                                url: '/hospital/setInv',
                                dataType: 'json',
                                type: 'post',
                                contentType: "application/json; charset=utf-8",
                                data:JSON.stringify({"id":obj.id}),
                                success: function (data) {

                                }
                            })
                        });

                    }
                }
            })

        });
        $(document).on('click', '#kuai', function () {

                layer.open({
                    type: 2,
                    area: ['800px', '450px'],
                    fixed: false,
                    maxmin: true,
                    shadeClose: true,
                    content: 'medQuick.html'
                });


        });
    })
</script>
<script>

  layui.use('myMoudle/console', layui.factory('console'));
</script>
<script>//上传

layui.use('form', function(){
    var $ = layui.jquery
        , form = layui.form;

    $.ajax({
        url: '/hospital/allSup',
        dataType: 'json',
        type: 'get',
        success: function (data) {
            $.each(data.data, function (index, item) {
                $('#supcoin').append("<option value = '" + item.id + "'>" + item.sup_name + "</option>");// 下拉菜单里添加元素
            });
        }
    })
    form.render("select");

})
layui.use('laydate', function(){//时间选择器
    var laydate = layui.laydate;
    laydate.render({
        elem: '#timeSelect'
    });
});
</script>

</body>
</html>
